
package top.kent90.controller;

import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import top.kent90.common.object.Result;
import top.kent90.pojo.ZczyOrder;
import top.kent90.service.ZczyOrderService;

import java.util.List;

@Controller
@RequestMapping("order")
public class ZczyOrderController {
    @Reference
    private ZczyOrderService zczyOrderService;
    @RequestMapping("toOrder")
    public String toOrder(){
        return "order/order";
    }

    @RequestMapping("findAll")
    @ResponseBody
    public Result findAll(@RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "size", required = true, defaultValue = "3") int size) throws Exception {

        List<ZczyOrder> orders = zczyOrderService.findAll(page, size);
        //PageInfo就是一个分页bean
        PageInfo pageInfo = new PageInfo(orders);
        return new Result("0","",pageInfo.getTotal(),pageInfo.getList());
//        mv.addObject("data",pageInfo.getList());
//        mv.setViewName("order/order");
//        return mv;

    }

    @RequestMapping("findById")
    public Result findById(Integer orderId) throws Exception {
        ZczyOrder order = zczyOrderService.findById(orderId);
        PageInfo pageInfo = new PageInfo((List) order);
        return new Result("0","", (long) 0,pageInfo.getList());
    }
    /*@RequestMapping("update")
    public String updateById(ZczyOrder zczyOrder) throws Exception{
        return "order/orderdetail";
    }*/
    @RequestMapping("toOrderAnalyse")
    public  String toOrderAnalyse() {
    return "order/orderadd";
    }
  /* @RequestMapping("update")
    public Result updateById(ZczyOrder zczyOrder) throws Exception{
    ZczyOrder zczyOrder1=zczyOrderService.updateById(zczyOrder);
    return new Result();

}*/
}

